{% extends 'base.html' %}
{% load static %}
{% load user_tags %}
{% block css %}

{% endblock %}
{% block title %}
    历史列表
{% endblock %}
{% block page-title %}
    历史列表
{% endblock %}
{% block page-content %}
     <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">查看历史列表</h3>
                </div>
                <div class="panel-body">
                    {% if messages %}
                        {% for message in messages %}
                            <div class="alert alert-{{ message.tags }} alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                {{ message }}
                            </div>
                        {% endfor %}
                    {% endif %}
                    <div class="row" style="margin-bottom: 5px">
                        <div class="col-md-2" style="float: right">
                            <form class="form-horizontal" role="form">
                                    <div class="input-group">
                                        <input type="text" id="keyword" name="keyword" class="form-control"  value="{{ keyword|default_if_none:'' }}" placeholder="关键字">
                                        <span class="input-group-btn">
                                        <button type="submit" class="btn btn-effect-ripple btn-primary">搜索</button>
                                        </span>
                                    </div>

                            </form>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>任务名称</th>
                                    <th>上线主机</th>
                                    <th>提交人</th>
                                    <th>提交时间</th>
                                    <th>审核人</th>
                                    <th>审核时间</th>
                                    <th>执行人</th>
                                    <th>执行时间</th>
                                    <th>状态</th>
                                    <th>动作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for task in page_obj.object_list %}
                                    <tr>
                                        <td>{{ task.task.name|cut:26 }}</td>
                                        <td title="{{ task.dest_hosts.all|get_host_names2}}">{{ task.dest_hosts.all|get_host_names2|cut:9 }}</td>
                                        <td>{{ task.apply_user }}</td>
                                        <td>{{ task.created_at }}</td>
                                        <td>{{ task.reviewer|default_if_none:'暂无' }}</td>
                                        <td>{{ task.review_at|default_if_none:'暂无' }}</td>
                                        <td>{{ task.publisher }}</td>
                                        <td>{{ task.publish_at }}</td>
                                        <td><label class="label {% if task.status == 1 %}label-danger{% elif task.status == 3 %}label-success{% endif %}">{{ task.get_status_display }}</label></td>
                                        <td>
                                            <a href="{% url 'task:task_detail' task.id %}?prev=history">查看</a>
                                        </td>

                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4">
                           <p style="margin-top: 10px"> 显示 [{{ page_obj.paginator.count }}] 条数据中的 第 [{{ page_obj.start_index }}] 至 [{{ page_obj.end_index }}] 的数据</p>
                        </div>
                        <div class="col-md-8">
                             {% if page_obj.paginator.num_pages > 1 %}
                                {% include '_paginator.html' %}
                             {% endif %}
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
        <script>
        $('.task').addClass('active');
        $('.task .task-history').addClass('active');
    </script>
{% endblock %}